// Kucik and Reinhardt 2008 IO

// Load original dataset
clear
use "KR2008 IO Rep Data.dta"

// REPLICATION
summarize
display c(k)
mdesc
tabmiss
codebook stnam1
codebook year
gen elnpercap = exp(lnpercap)
summarize

* MODEL 1*
biprobit (gattwto = adlaw lnpercap polity1 lngdp lnimports reggattwto2l1 gattwtol1 gwl1_adlaw gwl1_lnpercap gwl1_polity1 gwl1_lngdp gwl1_lnimports gwl1_reggattwto2l1)(adlaw = gattwto lnpercap polity1 lngdp lnimports adtarget regadlaw2l1 adlawl1 adl1_gattwto adl1_lnpercap adl1_polity1 adl1_lngdp adl1_lnimports adl1_adtarget adl1_regadlaw2l1) if eumembership~=1 & year>=firstyear & year<2004, robust
keep if eumembership~=1 & year>=firstyear & year<2004
codebook stnam1
codebook year
mdesc gattwto adlaw lnpercap polity1 lngdp lnimports reggattwto2l1 gattwtol1 gwl1_adlaw gwl1_lnpercap gwl1_polity1 gwl1_lngdp gwl1_lnimports gwl1_reggattwto2l adlaw gattwto lnpercap polity1 lngdp lnimports adtarget regadlaw2l1 adlawl1 adl1_gattwto adl1_lnpercap adl1_polity1 adl1_lngdp adl1_lnimports adl1_adtarget adl1_regadlaw2l1
codebook year if e(sample)
codebook stnam1 if e(sample)

// IMPUTATION
clear
use "KR2008 IO Imp Data.dta"
summarize

mi import flong, m(imp) id(stnam1 year) imp(gattwto-regtariffNEW2l1)

gen gattwto_new = gattwto - 1

* MODEL 1*
mi estimate, cmdok esampvaryok post: biprobit (gattwto_new = adlaw lnpercap polity1 lngdp lnimports reggattwto2l1 gattwtol1 gwl1_adlaw gwl1_lnpercap gwl1_polity1 gwl1_lngdp gwl1_lnimports gwl1_reggattwto2l1)(adlaw = gattwto_new lnpercap polity1 lngdp lnimports adtarget regadlaw2l1 adlawl1 adl1_gattwto adl1_lnpercap adl1_polity1 adl1_lngdp adl1_lnimports adl1_adtarget adl1_regadlaw2l1) if eumembership~=1 & year>=firstyear & year<2004, robust
